Skip to content

feat(opencode): add session backup API#25863

Open
drkaangunduz wants to merge 1 commit intoanomalyco:devfrom
drkaangunduz:feature/backup-api
Open

feat(opencode): add session backup API#25863
drkaangunduz wants to merge 1 commit intoanomalyco:devfrom
drkaangunduz:feature/backup-api

Conversation

@drkaangunduz
Copy link
Copy Markdown

@drkaangunduz drkaangunduz commented May 5, 2026

Issue for this PR

Closes #20117

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This adds a small backup API for sessions.

It introduces three endpoints:

  • POST /backup/list
  • POST /backup/export
  • POST /backup/import

/backup/export returns the full JSON payload for one session using the
existing session, message, and todo shapes.

/backup/import restores that payload as a new cloned session. It does not
reuse the original session, message, or part IDs, so importing a backup does
not overwrite an existing session by accident.

This also covers the same session round-trip gap described in #20117 by making
todos part of the exported and imported session payload.

The API is wired through both the Hono routes and the HttpApi routes so the
behavior stays consistent with the rest of the instance server.

I also regenerated the SDK output after adding the new endpoints.

How did you verify your code works?

  • Ran cd packages/opencode && bun typecheck
  • Ran cd packages/opencode && bun test test/server/httpapi-backup.test.ts
  • Built the binary with cd packages/opencode && bun run build
  • Started the built server locally and tested the endpoints manually
  • Verified POST /backup/list returns sessions
  • Verified POST /backup/export returns the full session JSON payload
  • Verified POST /backup/import creates a new session with a different ID
  • Verified exporting the imported session preserved the title and message count
  • Verified todos are included in the backup payload shape

Screenshots / recordings

Not applicable.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Expose minimal list, export, and import endpoints so sessions can be backed up as JSON and restored safely as cloned sessions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:title labels May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Hey! Your PR title add session backup API doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@drkaangunduz drkaangunduz changed the title add session backup API feat(opencode): add session backup API May 5, 2026
@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:title labels May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Include todos in session export/import

1 participant